package com.github.beihaifeiwu.myspring.http.feign;

import com.github.beihaifeiwu.myspring.core.MySpringConstants;
import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.util.ClassUtils;

/**
 * Created by liupin on 2017/9/5.
 */
@Data
@ConfigurationProperties(prefix = MySpringConstants.FEIGN_PROP_PREFIX)
public class FeignProperties {

    private int connectTimeoutMillis = 10 * 1000;
    private int readTimeoutMillis = 60 * 1000;

    private Logging logging = new Logging();
    private Retry retry = new Retry();

    @Data
    public static class Retry {
        private boolean enabled = true;
        private int maxAttempts = 5;
        private long period = 100;
        private long maxPeriod = 1000;
    }

    @Data
    public static class Logging {
        private Level level = Level.NONE;
        private String logName = ClassUtils.getPackageName(getClass());
        private org.slf4j.event.Level logLevel = org.slf4j.event.Level.DEBUG;

        public enum Level {
            NONE, BASIC, HEADERS, FULL
        }
    }

}
